# coding=utf-8

# 定投加速，最大买入增加50%
# 60定投加速0.5
# 55定投加速0.75
# 50定投加速1
# 45定投加速1.25
# 40定投加速1.5
# 35定投加速1.75
# 30定投加速2
# 回头，定投加速一倍，假如又一次跌倒上次低点，定投速度还原
current_price = 42
total_price = 100
total_money = 200000
buy_rate = [
    (0.60, 0.025),
    (0.59, 0.025),
    (0.58, 0.025),
    (0.57, 0.025),
    (0.56, 0.025),
    (0.55, 0.025),
    (0.54, 0.025),
    (0.53, 0.025),
    (0.52, 0.025),
    (0.51, 0.025),
    (0.50, 0.025),
    (0.49, 0.025),
    (0.48, 0.025),
    (0.47, 0.025),
    (0.46, 0.025),
    (0.45, 0.025),
    (0.44, 0.025),
    (0.43, 0.025),
    (0.42, 0.025),
    (0.41, 0.025),
    (0.40, 0.025),
    (0.39, 0.025),
    (0.38, 0.025),
    (0.37, 0.025),
    (0.36, 0.025),
    (0.35, 0.025),
    (0.34, 0.025),
    (0.33, 0.025),
    (0.32, 0.025),
    (0.31, 0.025),
    (0.30, 0.025),
    (0.29, 0.025),
    (0.28, 0.025),
    (0.27, 0.025),
    (0.26, 0.025),
    (0.25, 0.025),
    (0.24, 0.025),
    (0.23, 0.025),
    (0.22, 0.025),
    (0.21, 0.025),
]

buy_price = 0
buy = []
for item in buy_rate:
    if item[0] * total_price < current_price:
        break
    buy_price += total_money * item[1]
    buy.append((item[0] * total_price, total_money * item[1] / (item[0] * total_price)))
loss_price = 0
buy_number = 0
for item_buy in buy:
    buy_number += item_buy[1]
    loss_price += (item_buy[0] - current_price) * item_buy[1]
print(buy_price)
print(loss_price)
print(loss_price / buy_number)
exit()
